/**
 * 番茄钟相关路由
 */
const express = require('express');
const router = express.Router();
const pomodoroController = require('../controllers/pomodoroController');
const authenticate = require('../middleware/auth');
const validator = require('../middleware/validator');

// 所有番茄钟路由都需要认证
router.use(authenticate);

// 获取番茄钟历史记录
router.get('/', pomodoroController.getHistory);

// 获取番茄钟统计信息
router.get('/statistics', pomodoroController.getStatistics);

// 开始番茄钟
router.post(
  '/start',
  pomodoroController.startPomodoro
);

// 结束番茄钟
router.put(
  '/:id/end',
  validator.validateIdParam(),
  validator.validateRequired(['status']),
  pomodoroController.endPomodoro
);

module.exports = router; 